﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BestCode.Creds.View.Model;
using Didsoft.Wpf.ViewModel;

namespace BestCode.Creds.View.ViewModel
{
    public class VmEditFoto : BindableObject
    {
        private string nombres;
        public string Nombres
        {
            get { return nombres; }
            set
            {
                nombres = value; this.FirePropertyChanged("Nombres");

            }
        }

        private Dato selectedStudent;
        public Dato SelectedStudent
        {
            get { return selectedStudent; }
            set
            {
                selectedStudent = value;
                if (selectedStudent != null)
                    Nombres = selectedStudent.ApellidoPaterno + " " + selectedStudent.ApellidoMaterno + " " +
                              selectedStudent.Nombres; 

                 this.FirePropertyChanged("SelectedStudent");
            }
        }

        //private CREDSEntities dbContext = null;

        public VmEditFoto()
        {
            //dbContext = new CREDSEntities();
        }

        public void UpdateFoto()
        {
            DataFactory.Current.DBContext.Datos.Attach(SelectedStudent);
            

            DataFactory.Current.DBContext.Entry(SelectedStudent).State = EntityState.Modified;
            DataFactory.Current.DBContext.SaveChanges();
        }


    }
}
